﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using Microsoft.Extensions.DependencyInjection;
using OwnerTools.viewmodel;

namespace OwnerTools
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {

        public App()
        {
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddSingleton<MainWindow>();
            serviceCollection.AddSingleton<Login>();
            serviceCollection.AddSingleton<UserViewModel>();

            _serviceProvider = serviceCollection.BuildServiceProvider();
        }
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            var login = _serviceProvider.GetService<Login>();
            login!.ShowDialog();
            var uvm = _serviceProvider.GetService<UserViewModel>();
            if (uvm is not null)
            {
                MessageBox.Show($"Login Result: {uvm.IsLoggedIn}");
            }
        }
    }
}
